package ch.ethz.fcl.metrobuzz.controller.gui.swing;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import net.miginfocom.swing.MigLayout;
import ch.ethz.fcl.metrobuzz.MBContainer;

public class ViewerControlPanel extends JPanel {
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unused")
	private MBContainer container;

	JButton resetColor;
	JButton save;
	JCheckBox temporal;
	JCheckBox detail;
	JCheckBox inout;

	JButton compare;
	JButton uncompare;

	public ViewerControlPanel(MBContainer container) {
		super(new MigLayout());
		this.container = container;

		setBackground(Color.lightGray);
		setBorder(BorderFactory.createTitledBorder("Viewer Control"));

		resetColor = new JButton("Reset Color");
		resetColor.addActionListener(new ButtonClickListener());

		save = new JButton("Save");
		save.addActionListener(new ButtonClickListener());

		compare = new JButton("Compare");
		compare.addActionListener(new ButtonClickListener());

		uncompare = new JButton("Uncompare");
		uncompare.addActionListener(new ButtonClickListener());

		temporal = new JCheckBox("Temporal View", false);
		temporal.addChangeListener(new CheckBoxChangeListener());

		detail = new JCheckBox("Detail View", false);
		detail.addChangeListener(new CheckBoxChangeListener());

		inout = new JCheckBox("In/Out View", false);
		inout.addChangeListener(new CheckBoxChangeListener());

		add(detail, "span, grow");
		add(temporal, "span, grow");
		// add(inout, "span, grow");

		add(resetColor);
		add(save, "span, grow");
	}

	class ButtonClickListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent event) {
			Object source = event.getSource();
			if (source instanceof JButton) {
				// JButton button = (JButton) source;
				// if (button.equals(save)) {
				// container.getData().getSGInterchange()
				// .saveRegionInfo(container.getRender());
				// }

				// else if (button.equals(resetColor))
				// container.getData().getSGInterchange().updateRegionColors();
			}
		}
	}

	class CheckBoxChangeListener implements ChangeListener {
		@Override
		public void stateChanged(ChangeEvent event) {
			Object source = event.getSource();
			if (source instanceof JCheckBox) {
			}
		}
	}
}
